from selenium.webdriver.common.by import By
from time import sleep

class BuyFinancePage():

    def __init__(self,driver):
        self.driver = driver

    def buyFinanceLin(self,pay_pwd):
        # 点击个人理财
        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/a").click()
        # 点击零钱理财
        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a").click()
        # 点击投资
        self.driver.find_element(By.XPATH,
                            "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button").click()
        # 输入支付密码
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/input").send_keys(pay_pwd)
        # 点击确定按钮
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[3]/a[1]").click()
        # 获取文本信息
        text = self.driver.find_element(By.XPATH,
                                      "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text
        # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button").click()
        return text

    def buyFinanceLin2(self,pay_pwd):
        # 点击个人理财
        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/a").click()
        # 点击期限理财

        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[2]/a").click()
        # 点击投资
        self.driver.find_element(By.XPATH,
                            "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button").click()
        # 输入支付密码
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/input").send_keys(pay_pwd)
        # 点击确定按钮
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[3]/a[1]").click()
        # 获取文本信息
        text = self.driver.find_element(By.XPATH,
                                      "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text
        # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button").click()
        return text

    def buyFinanceLin3(self,pay_pwd):
        # 点击个人理财
        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/a").click()
        # 点击基金理财

        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a").click()
        # 点击投资
        self.driver.find_element(By.XPATH,
                            "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button").click()
        # 输入支付密码
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/input").send_keys(pay_pwd)
        # 点击确定按钮
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[3]/a[1]").click()
        # 获取文本信息
        text = self.driver.find_element(By.XPATH,
                                      "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text
        # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button").click()
        return text
    def buyFinanceLin4(self,pay_pwd):
        # 点击个人理财
        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/a").click()
        # 点击基金理财

        self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a").click()
        # 点击投资
        self.driver.find_element(By.XPATH,
                            "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button").click()
        # 输入支付密码
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/input").send_keys(pay_pwd)
        # 点击确定按钮
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[3]/a[1]").click()
        sleep(5)
        # 获取文本信息
        text = self.driver.find_element(By.XPATH,
                                      "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text
        # 点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[4]/button").click()
        return text
